package com.kira.solo.schedule

import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import com.kira.solo.schedule.edit.ScheduleEditTask
import com.kira.solo.schedule.list.ScheduleList

/**
 *  定时器页面
 * @package com.kira.solo.schedule
 * @date 2024/1/23
 * @author zhanglei
 */
@Composable
fun ScheduleScreen(
    navHostController: NavHostController = rememberNavController(),
    onFinish: () -> Unit,
) {
    NavHost(
        navController = navHostController,
        startDestination = "schedule_list"
    ) {
        composable("schedule_list") {
            ScheduleList(editTask = { navHostController.navigate("schedule_edit/$it") }) { onFinish() }
        }
        composable(
            "schedule_edit/{taskId}",
            arguments = listOf(navArgument("taskId") { type = NavType.LongType })
        ) {
            ScheduleEditTask {
                navHostController.popBackStack()
            }
        }
    }
}